/*
 * @Author: your name
 * @Date: 2021-08-31 20:20:56
 * @LastEditTime: 2021-08-31 20:20:57
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day07\12-迭代的应用.js
 */

var stus = [
    { name: '张三', age: 20 },
    { name: '李四', age: 30 },
    { name: '王五', age: 10 },
    { name: '陈六', age: 3 }
];

//排序
//1.有没有成年人
var bool = stus.some(function(value) {
    return value.age >= 18;
});
console.log(bool);
//2.有没有未成年人
var bool = stus.some(function(value) {
    return value.age < 18;
});
//3.是否都成年
var bool = stus.every(function(obj) {
    return obj.age >= 18;
});
//4.把未成年人找到
var arr = stus.filter(function(obj) {
    return obj.age < 18;
});
console.log(arr);
//5.找到所有的用户名  obj.name
var arr = stus.map(function(obj) {
    //return obj.name;
    return 'work_' + obj.name;
});
console.log(arr);
//6.找到所有的年龄 obj.age
var arr = stus.map(function(obj) {
    return obj.age;
});
console.log(arr);
//7.按照td格式输出打印
arr.forEach(function(value) {
    console.log("<td>" + value + "</td>");
});